#include "ros/ros.h"
#include "robo/adc_val.h"
#include "std_msgs/Int32.h"
#include "std_msgs/String.h"
#include <stdlib.h>

using namespace robo;

void chatterCallback(const adc_val::ConstPtr& msg)
{
  ROS_INFO("I heard: [%i, %i, %i, %i, %i, %i, %i, %i]",msg->val0,msg->val1,msg->val2,msg->val3,msg->val4,msg->val5,msg->val6,msg->val7);
}

int main(int argc, char **argv)
{
	ros::init(argc, argv, "adc_tester");
	ros::NodeHandle n;
	ros::Subscriber sub = n.subscribe("roboard/adc", 5000, chatterCallback);
	ros::Publisher chatter_pub = n.advertise<std_msgs::Int32>("roboard/adc_interval", 1000);
	ros::Rate loop_rate(100);
	while (ros::ok())
	{
		if(rand()%500 == 0)
		{
			std_msgs::Int32 msg;		
			msg.data = 10+rand()%991;
			chatter_pub.publish(msg);
		}
		ros::spinOnce();
		loop_rate.sleep();
	}
	return 0;
}
